﻿Imports Lucene.Net.Analysis
Imports System.IO

Namespace Aricie.DNN.Modules.LuceneSearch.Business

    Public Class SynonymAnalyzer
        Inherits Analyzer

        Private _synonymEngine As ISynonymEngine
        Private _subAnalyzer As Analyzer

        Public Sub New(ByVal engine As ISynonymEngine, ByVal subAnalyzer As Analyzer)
            Me._synonymEngine = engine
            Me._subAnalyzer = subAnalyzer
        End Sub

        Public Overrides Function TokenStream(ByVal fieldName As String, ByVal reader As TextReader) As TokenStream
            Return New SynonymFilter(Me._subAnalyzer.TokenStream(fieldName, reader), Me._synonymEngine)
        End Function

        Public Property SubAnalyzer() As Analyzer
            Get
                Return Me._subAnalyzer
            End Get
            Set(ByVal value As Analyzer)
                Me._subAnalyzer = value
            End Set
        End Property

        Public Property SynonymEngine() As ISynonymEngine
            Get
                Return Me._synonymEngine
            End Get
            Set(ByVal value As ISynonymEngine)
                Me._synonymEngine = value
            End Set
        End Property

    End Class

End Namespace


